'use strict'

module.exports = app => {
	const { STRING, INTEGER, DATE } = app.Sequelize
	const Tag = app.model.define('tag', {
		id: { type: INTEGER, primaryKey: true, autoIncrement: true },
		tagName: {
			type: STRING(30),
			comment: '分类名称',
		},
		createdAt: {
			type: DATE,
			comment: '创建日期',
		},
		updatedAt: {
			type: DATE,
			comment: '更新日期',
		},
	})
	Tag.associate = function () {
		app.model.Tag.hasMany(app.model.Article, { foreignKey: 'tagId' })
	}
	return Tag
}
